<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>hello_react</title>
</head>
<body>
    <div id="test1"></div>
    <div id="test2"></div>

    <!-- 引入 react 核心库 -->
    <script src="./js/react.development.js" type="text/javascript"></script> <!-- React 对象 -->
    <script src="./js/react-dom.development.js" type="text/javascript"></script> <!-- ReactDOM 对象 -->
    <script src="./js/babel.min.js" type="text/javascript"></script> <!-- babel -->
    <script src="./js/prop-types.js" type="text/javascript"></script> <!-- PropTypes -->

    <script type="text/babel">
        function Person (props) {
            const {name, sex, age} = props
            return (
                <ul>
                    <li>姓名：{name}</li>    
                    <li>性别：{sex}</li> 
                    <li>年龄：{age+1}</li>
                </ul>
            )
        }
        // 对 props 进行约束
        Person.propTypes = {
            name: PropTypes.string.isRequired,
            sex: PropTypes.string,
            age: PropTypes.number,
            speak: PropTypes.func
        }
        Person.defaultProps = {
            sex: '女',
            age: 18
        }
        ReactDOM.render(<Person name="jerry" sex="男" age={50} />, document.querySelector('#test1'))
        ReactDOM.render(<Person name="tom" />, document.querySelector('#test2'))
    </script>
</body>
</html>